package com.hyf.translucentstatusbar;

import android.content.Intent;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.GradientDrawable;
import android.os.Bundle;
import android.view.View;
import android.widget.ListView;

import com.hyf.translucentstatusbar.activity.Base;
import com.hyf.translucentstatusbar.activity.DefaultBaseActivity;
import com.hyf.translucentstatusbar.activity.HeaderActivity;
import com.hyf.translucentstatusbar.activity.ImageHeaderActivity;
import com.hyf.translucentstatusbar.activity.NavigationActivity;
import com.hyf.translucentstatusbar.activity.TestStatusBarActivity;
import com.hyf.translucentstatusbar.activity.TranslucentActivity;
import com.hyf.translucentstatusbar.adapter.MainListViewAdapater;
import com.hyf.translucentstatusbar.entity.MainItem;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;

public class MainActivity extends Base {

    @BindView(R.id.lv_main)
    ListView mListView;


    private List<MainItem> mItemList = new ArrayList<>();
    public static MainActivity mActivity;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        toolBar.setTitle(R.string.app_name);
        ButterKnife.bind(this);
        mActivity = this;
        MainListViewAdapater adapater = new MainListViewAdapater(mItemList, this);
        mListView.setAdapter(adapater);
        initData();
        adapater.notifyDataSetChanged();
    }

    @Override
    protected Drawable onHeaderBarDrawable() {
        int[] colors = {getResources().getColor(R.color.colorPrimary), getResources().getColor(R.color.colorPrimaryLight)};
        return new GradientDrawable(GradientDrawable.Orientation.LEFT_RIGHT, colors);
    }

    private void initData() {
        mItemList.add(new MainItem("默认的效果", new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                startActivity(new Intent(mActivity, DefaultBaseActivity.class));
            }
        }));

        mItemList.add(new MainItem("沉浸式状态栏", new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                startActivity(new Intent(mActivity, TranslucentActivity.class));
            }
        }));

        mItemList.add(new MainItem("ImageHeaderActivity", new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                startActivity(new Intent(mActivity, ImageHeaderActivity.class));
            }
        }));

        mItemList.add(new MainItem("HeaderActivity", new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                startActivity(new Intent(mActivity, HeaderActivity.class));
            }
        }));

        mItemList.add(new MainItem("NavigationView沉浸式侧滑菜单", new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                startActivity(new Intent(mActivity, NavigationActivity.class));
            }
        }));

        mItemList.add(new MainItem("打开测试状态栏activity", new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                startActivity(new Intent(mActivity, TestStatusBarActivity.class));
            }
        }));
    }

    @Override
    protected boolean isImageHeader() {
        return false;
    }
}
